package com.quanquan.management.controller;

import DTO.PageDTO;
import com.quanquan.management.dto.PermissionDTO;
import com.quanquan.management.dto.PermissionResultDTO;
import com.quanquan.management.dto.SysPermissionDTO;
import com.quanquan.management.service.SysPermissionService;
import enums.ResCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import web.response.ResultBody;

import java.util.LinkedList;

/**
 * 功能描述: 角色权限管理
 *
 * @ClassName: SysPermissionController
 * @Author: xiaoqianh丶
 * @Date: 2019-08-13 13:59
 * @Version: V1.0
 */
@Controller
@RequestMapping("/sys_permission")
public class SysPermissionController {

    @Autowired
    private SysPermissionService sysPermissionService;

    @GetMapping("/query")
    @ResponseBody
    public ResultBody queryPermission (){

        PageDTO<SysPermissionDTO> pageDTO = sysPermissionService.queryAllPermission();

        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), ResCodeEnum.SUCCESS.getMsg(),pageDTO);
    }

    @GetMapping("/queryTest")
    @ResponseBody
    public ResultBody queryPermissionTest(){

        LinkedList<PermissionDTO> permissionDTOS = sysPermissionService.queryResult();

        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), ResCodeEnum.SUCCESS.getMsg(),permissionDTOS);
    }

    @GetMapping("/query_edit")
    @ResponseBody
    public ResultBody queryPermissionTest(String roleId){

        PermissionResultDTO permissionResultDTO = sysPermissionService.queryResultEdit(roleId);

        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), ResCodeEnum.SUCCESS.getMsg(),permissionResultDTO);
    }
}
